export default {
  counters: (state = {counter: 0}, action) => {
    switch (action.type) {
      case 'INC_COUNTER':
        const counter = state.counter + (action.value || 1);
        return Object.assign({}, state, {counter});
      case 'RESET_COUNTER':
        return Object.assign({}, state, {counter: 0});
      case 'RAND_COUNTER':
        const max = 100;
        const min = 0;
        return Object.assign({}, state, {
          counter: Math.floor(Math.random() * (max - min)) + min
        });
      default:
        return state;
    }
  }
};
